import { useEffect, useState } from 'react'
import { Request, fetchMessageAPI } from '@/apis/message'
// import { log } from 'console'

function useForm(data:Request) {
  const [res, setRes] = useState<number>()
  console.log(data);
  
  useEffect(() => {
    const getBanners = async () => {
      try {
        const res = await fetchMessageAPI(data)
        console.log(res);
        // if (res.data.code === 200) {
        //   console.log(res.data.data);
          
        // }
        setRes(res.data.code)
      } catch (error) {
        throw new Error('fetch banners error')
      }
    }
    getBanners()
  }, [])
  // 暴露数据channels
  return {
    res,
  }
}

export { useForm }
